<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let sym1 = Symbol(); //表示独一无二的值

        //1.定义对象
        let obj = {
            id:1,
            name:"小王八",
            [sym1]:"我是独一无二的"
        };
        console.log(obj);

        //2.获取到对象中所有的key   Symbol的没有获取到
        console.log(Object.keys(obj)); // ['id', 'name']

        //3.获取值为 Symbol的key
        console.log(Object.getOwnPropertySymbols(obj)); //[Symbol()]


        //4.Reflect:内置对象，统一操作方式，更加简单化，优雅化
        console.log(Reflect); //Reflect {defineProperty: ƒ, deleteProperty: ƒ, apply: ƒ, construct: ƒ, get: ƒ, …}

        //5.获取所有的key
        console.log(Reflect.ownKeys(obj)); // ['id', 'name', Symbol()]

        //6.获取对象的值  Reflect.get(target,key)
        console.log(Reflect.get(obj,"name")); //小王八

        //7.设置对象的值 Reflect.set(target,key,value)
        Reflect.set(obj,"name","王昭君");
        console.log(obj); //{id: 1, name: '王昭君', Symbol(): '我是独一无二的'}


        //8.删除对象的可以 Reflect.deleteProperty(target,key)
        Reflect.deleteProperty(obj,"id");
        console.log(obj); //{name: '王昭君', Symbol(): '我是独一无二的'}



    </script>
</body>
</html>